#ifndef SCOPE_TYPE_H
#define SCOPE_TYPE_H

#ifdef __cplusplus
extern "C" {
#endif

#define SCOPE_CFG_FILE          "/scope_cfg.bin"

typedef enum {
    SCOPE_CHN_0,
    SCOPE_CHN_1,
    SCOPE_CHN_BUTT
} SCOPE_CHN;

typedef enum {
    SCOPE_SCALE_0,
    SCOPE_SCALE_1,
    SCOPE_SCALE_2,
    SCOPE_SCALE_BUTT
} SCOPE_SCALE;

typedef enum {
    SCOPE_EDGE_RISING = 0,
    SCOPE_EDGE_FALLING = 1,
    SCOPE_EDGE_BOTH = 2,
    SCOPE_EDGE_BUTT
} SCOPE_EDGE;

typedef enum {
    SCOPE_MODE_NORMAL = 0,
    SCOPE_MODE_SINGLE = 1,
    SCOPE_MODE_BUTT,
} SCOPE_MODE;

typedef enum {
    SCOPE_COUPLING_DC = 0,
    SCOPE_COUPLING_AC = 1,
    SCOPE_COUPLING_BUTT
} SCOPE_COUPLING;

#define PING              false
#define PONG              true
#define PINGPONG            2
typedef bool              pingpong_t;

typedef struct {
    uint8_t ch0;
    uint8_t ch1;
} scope_adc_data;

typedef struct {
    int32_t ch0_min;
    int32_t ch0_max;
    int32_t ch1_min;
    int32_t ch1_max;
} scope_snap_data;

typedef struct {
    int gnd[3];
    int gnd_trigger[3];
    int scale[3];
} scope_cali_ch;

typedef struct {
    uint32_t magic1;
    scope_cali_ch ch[2];
    uint32_t magic2;
} scope_cali_data;


typedef struct {
    uint32_t rate;
    bool running;
    bool ch0_enable;
    bool ch1_enable;
    SCOPE_SCALE ch0_scale;
    SCOPE_SCALE ch1_scale;   
     
    int ch0_div_mv;
    int ch1_div_mv;
    int ch0_gnd_mv;
    int ch1_gnd_mv;

    SCOPE_CHN trigger_chnl;
    SCOPE_EDGE trigger_edge;
    SCOPE_MODE trigger_mode;
    int trigger_level_mv;

    int dma_chan_adc_data;
    int dma_chan_psram_data;
    int dma_chan_psram_ctrl;
    int trigger_dma_chan;

    scope_cali_data cali_data;
    uint32_t time_div_us;

    uint32_t measure_flag;
} scope_cfg_t;

#ifdef __cplusplus
}
#endif

#endif
